package com.caoaman.sharding.controller;

import com.caoaman.sharding.model.Order;
import com.caoaman.sharding.service.IOrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName: OrderController
 * @Description: 控制器
 * @Author: CaoAMan
 * @Create: 2021-12-19 15:02
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @Resource
    private IOrderService orderService;

    @GetMapping("create")
    public void createTable(){
        orderService.createTable();
    }

    @PostMapping("insertOrder")
    public void insertOrder() {
        final Date saveTime = new Date();
        final long saveTimeCom = saveTime.getTime();
        System.out.println("当前时间的毫秒是：" + saveTimeCom);
        final Order order =
                new Order(1, 2, 3, 4, 5, saveTime, saveTimeCom, 1, 2, 3, 4, 5, 6,
                        (float) 7, (float) 8, (float) 9, (float) 10, (float) 11,
                        (float) 12, (float) 13, (float) 14, (float) 15, (float) 16,
                        (float) 17, (float) 18, (float) 19);
        orderService.save(order);
    }
}
